package com.example.designpatterns.adapter;

import com.example.designpatterns.observer.WeatherStation;

// 适配器类，将 WeatherStation 的温度更新逻辑适配为 TemperatureProvider 接口
public class TemperatureAdapter implements TemperatureProvider {
    private WeatherStation weatherStation;

    public TemperatureAdapter(WeatherStation weatherStation) {
        this.weatherStation = weatherStation;
    }

    @Override
    public float getTemperature() {
        // 获取摄氏温度
        float celsiusTemperature = weatherStation.getTemperature();
        // 将摄氏温度转换为华氏温度
        float fahrenheitTemperature = (celsiusTemperature * 9/5) + 32;
        return fahrenheitTemperature;
    }
}